package com.gitee.liang521.generate.api.controller;

import com.gitee.liang521.generate.api.pojo.vo.generate.GenerateReqVo;
import com.gitee.liang521.generate.api.pojo.vo.generate.ListResVo;
import com.gitee.liang521.generate.api.service.GenerateService;
import com.gitee.liang521.generate.common.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author liang zai
 * @date 2021/9/16 14:48
 * @description
 */
@Api(value = "GenerateController", tags = "代码生成器")
@RequestMapping("generate")
@RestController
public class GenerateController {

    @Resource
    private GenerateService generateService;

    @GetMapping("tables")
    @ApiOperation(value = "数据列表", response = ListResVo.class)
    public R list(){
       return R.success(generateService.listQuery());
    }

    @GetMapping("types")
    @ApiOperation(value = "生成文件类型", response = List.class)
    public R types(){
        return R.success(generateService.types());
    }

    @GetMapping("generate")
    @ApiOperation(value = "生成代码")
    public R generate(GenerateReqVo generateReqVo){
        generateService.generate(generateReqVo);
        return R.success();
    }
}
